﻿using System;
using System.Linq;
using System.Runtime.Serialization;
using System.ServiceModel;
using System.ServiceModel.Activation;
using System.ServiceModel.Web;

[ServiceContract(Namespace = "")]
[AspNetCompatibilityRequirements(RequirementsMode = AspNetCompatibilityRequirementsMode.Allowed)]
public class ProductService
{
    // Add [WebGet] attribute to use HTTP GET
    [OperationContract, WebGet]
    public void ChangeProductFeatured(string featured, int productId)
    {
        using (DAL.EShopDBDataContext db = new DAL.EShopDBDataContext())
        {
            var product = db.Products.Single(c => c.ProductId == productId);
            product.Featured = bool.Parse(featured);
            db.SubmitChanges();
        }
    }
}
